package xin.nick.cloud.code.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.nick.cloud.code.util.EmailSender;

/**
 * @author Nick
 * @date 2021/8/1
 * @description
 */
@RestController
@Slf4j
public class EmailController {

   @Autowired
   private EmailSender emailSender;

    @RequestMapping("/email/{email}/{code}")
    public boolean sendEmail(@PathVariable("email") String email,
                             @PathVariable("code") String code) {
        log.info("发送邮件验证码啦~ {}:{}",email, code);

        emailSender.sendEmail(email, code);

        return true;

    }

}
